home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
Profile.pxl
< prev
next >
Wrap
Text File
|
2001-05-08
|
6KB
|
221 lines
{ Sample PiXCL 4.4 source file. Can be freely copied or adapted. }
Initialize:
UseCoordinates(PIXEL)
UseFont("Arial",5,15,NOBOLD,NOITALIC,NOUNDERLINE,0,0,255)
SetColorPalette(GENERATE)
Title$ = "Profiling Pixel Values and Histograms"
UseCaption(Title$)
WinLocate(Title$,200,100,760,550,Res)
WinShow(Title$,TOPMOST,Res)
DirGet(SourceDir$)
SampleBitmap$ = "..\samples\geol.bmp"
State = 0
UseBrush(SOLID,128,128,128)
InfoMenu(REMOVE)
SetMenu("File",IGNORE,
"E&xit",Leave,
ENDPOPUP,
"&Help",Help,
ENDPOPUP,
"&About",About,
ENDPOPUP)
DrawText(100,90,"Click anywhere to start")
SetMouse(0,40,400,410,Profile,X,Y)
StatusWindow(ENABLE,BOTTOM,3,180,300,-1,0)
Toolbar(RAISED, PXL_LARGE,
HISTOGRAM,ENABLED,CHECK,"Toggle Channel Histograms",CreateHistograms,
HELPINFO,ENABLED,STD,"Show Help",Help,
NULL,NULL,SEPARATOR,"",Dummy,
PXL_PRINT,ENABLED,STD,"Print Client Area scaled to page",PrintClientArea,
NULL,NULL,SEPARATOR,"",Dummy,
IMAGEINFO,ENABLED,STD,"About Profiling",About)
ChangeToolbarBtn("",1,DISABLED,Res)
ChangeToolbarBtn("",4,DISABLED,Res)
Wait_for_Input:
Dummy:
GoSub UpdateTime
WaitInput(10000)
Goto Wait_for_Input
Leave:
End
About:
AboutUser("About Profile","PiXCL Sample program","")
Goto Wait_for_Input
PrintClientArea:
{identify the current client area, save the bitmap in a temp
file, then print the bitmap and delete the temp file}
TempFile$ = SourceDir$ + "\clientimage.bmp"
WinGetClientRect("",cx1,cy1,cx2,cy2)
cy1 += 32 cy2 -= 28 {ignore the toolbar and statusbar regions}
SaveRectangle(cx1,cy1,cx2,cy2, TempFile$, BACKGND,Res)
PrintBitmap(TempFile$,PRINT_PAGERES,Res)
FileDelete(TempFile$,Res)
Goto Wait_for_Input
CreateHistograms:
WaitInput(100)
If State = 0
State = 1
{have to convert to 24 bit color space to show channel histograms}
DrawBitMap(0,40,SampleBitmap$ ){400x324}
ConvertColorSpace(RGB24,NONE,Res)
GetChannel(RED,RedHandle)
GetChannel(GREEN,GreenHandle)
GetChannel(BLUE,BlueHandle)
{now create the histograms}
Histogram(530,100,POPUP, SampleBitmap$,RedHandle,NONCUM,"Red",Histogram1,
530,260,POPUP, SampleBitmap$,GreenHandle,NONCUM,"Green",Histogram2,
530,420,POPUP, SampleBitmap$, BlueHandle,NONCUM,"Blue", Histogram3)
WinSetActive(Title$,Res)
Else
State = 0
Histogram()
Endif
Goto Wait_for_Input
Profile:
UseBackground(TRANSPARENT,166,166,166)
DrawBackGround
SetMouse(0,40,400,410,Start,X,Y)
SetRightMouse()
Start:
GoSub UpdateStatusDisplay
ChangeToolbarBtn("",1,ENABLED,Res)
ChangeToolbarBtn("",4,ENABLED,Res)
WaitInput(1)
SetColorPalette(GENERATE)
DrawBitMap(0,40,SampleBitmap$){400x324}
WaitInput(1) {let windows catch up}
DrawStatusWinText(0,SampleBitmap$)
UseCaption(Title$)
UsePen(NULL,1,0,0,0)
UseBrush(SOLID,255,255,255)
DrawEdgeRectangle(400,40,420,364,RAISEDEDGE,ADJUST,LEFT)
DrawEdgeRectangle(408,41,542,126,SUNKENEDGE,ADJUST,RECT)
DrawEdgeRectangle(408,129,542,214,SUNKENEDGE,ADJUST,RECT)
DrawEdgeRectangle(408,219,542,304,SUNKENEDGE,ADJUST,RECT)
DrawRectangle(410,43,540,124)
DrawRectangle(410,131,540,212)
DrawRectangle(410,221,540,302)
X = 0
Xg = 411
MaxR = 0 MinR = 255
MaxG = 0 MinG = 255
MaxB = 0 MinB = 255
UseCursor(WAIT)
Loop:
GetPixel(X,Y,R,G,B,Res)
If R > MaxR Then MaxR = R
If G > MaxG Then MaxG = G
If B > MaxB Then MaxB = B
If R < MinR Then MinR = R
If G < MinG Then MinG = G
If B < MinB Then MinB = B
X = X + 2
Xg = Xg + 1
R = R / 4 G = G / 4 B = B / 4
UsePen(SOLID,1,0,0,255) Y1 = 123 - B
DrawLine(Xg,123,Xg,Y1)
UsePen(SOLID,1,0,128,0) Y2 = 211 - G
DrawLine(Xg,211,Xg,Y2)
UsePen(SOLID,1,255,0,0) Y3 =301 - R
DrawLine(Xg,301,Xg,Y3)
If X < 252 Then Goto Loop
DrawNumber(440,44,MinB) DrawNumber(480,44,MaxB)
DrawNumber(440,132,MinG) DrawNumber(480,132,MaxG)
DrawNumber(440,222,MinR) DrawNumber(480,222,MaxR)
UsePen(SOLID,1,255,255,255)
DrawLine(0,Y,400,Y)
UseCursor(ARROW)
SetRightMouse(410,42,540,124,BluProfile,Xx,Yy,
410,130,540,212,GrnProfile,Xx,Yy,
410,220,540,302,RedProfile,Xx,Yy)
Goto Wait_for_Input
Help:
MessageBox(OK,1,INFORMATION,
"To run this sample program, click anywhere in the window,
and an image is displayed. The line at the X coordinate
that you clicked is scanned for the display RGB pixel
values, and three profiles are drawn to the right of the
image, plus the minimum and maximum values for each color
in the scanned line.
The Histogram button toggles the display of the individual
Red, Green and Blue histograms. The Print button captures
the current client area and sends it to a selected printer,
scaled to the current page size.
Both are disabled at the start of the program, and enabled
when the sample image is loaded.
This program is best viewed with a 2MB or better video card
with 16 or 24 bit color mode enabled.",
"Profiling Pixel values",Res)
Goto Wait_for_Input
RedProfile:
MessageBox(OK,1,EXCLAMATION,
"These are the pixel values read from the display
memory, not from the image file itself.",
"Profile of the Red pixels.",Res)
Goto Wait_for_Input
GrnProfile:
MessageBox(OK,1,EXCLAMATION,
"These are the pixel values read from the display
memory, not from the image file itself.",
"Profile of the Green pixels.",Res)
Goto Wait_for_Input
BluProfile:
MessageBox(OK,1,EXCLAMATION,
"These are the pixel values read from the display
memory, not from the image file itself.",
"Profile of the Blue pixels.",Res)
Goto Wait_for_Input
UpdateStatusDisplay:
Str(X,X$) X$ = X$ + "," Str(Y,Y$) Y$ = Y$ + " selected."
Msg$ = X$ + Y$
DrawStatusWinText(1,Msg$)
Return
UpdateTime:
TimeToASCII(LOCAL,WDDDMYYYY,Date$)
AppWindowHandle(Handle,Handle$, geoPiXCLFlag,PXLMajor,Minor)
If PXLMajor = 5
GetLocalTime(n,n,n,n,Hour,Minimum,Sec)
Else
GetLocalTime(n,n,n,n,Hour,Minimum)
Endif
Str(Hour,Hour$) Hour$ = Hour$ + ":"
Str(Minimum,Minimum$)
If Minimum < 10 Then Minimum$ = "0" + Minimum$
Minimum$ = Minimum$ + " "
TimeString$ = Hour$ + Minimum$
TimeString$ = TimeString$ + Date$
DrawStatusWinText(2,TimeString$)
Return